using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace AtlantisRevenge.GamePlay
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    class Botao
    {
        bool MouseNoSprite;
        public Texture2D textura;
        string nome;
        public Vector2 posicao;

        public Botao(ContentManager Content, GameWindow Window, string Textura)
        {
            textura = Content.Load<Texture2D>(Textura);
            nome = Textura;
        }

        public void Update(GameTime gameTime)
        {
            Main.CurrentMouseState = Mouse.GetState();

            if ((Main.CurrentMouseState.X >= posicao.X && Main.CurrentMouseState.X <= posicao.X + textura.Width) && (Main.CurrentMouseState.Y >= posicao.Y && Main.CurrentMouseState.Y <= posicao.Y + textura.Height / 2))
            {
                MouseNoSprite = true;
            }
            else
            {
                MouseNoSprite = false;
            }

            if (Main.CurrentMouseState.LeftButton == ButtonState.Pressed && Main.LastMouseState.LeftButton == ButtonState.Released)
            {
                if (MouseNoSprite)
                {
                    if (this.nome == "Botoes/jogar")
                    {
                        EstadoBase.estado_atual = EstadoBase.Estado.JOGO;
                    }
                    else if (this.nome == "Botoes/creditos")
                    {
                        EstadoBase.estado_atual = EstadoBase.Estado.CREDITOS;
                    }
                    else if (this.nome == "Botoes/sair")
                    {
                        EstadoBase.estado_atual = EstadoBase.Estado.SAIR;
                    }
                    else if (this.nome == "Botoes/recordes")
                    {
                        EstadoBase.estado_atual = EstadoBase.Estado.RECORDES;
                    }
                    else if (this.nome == "Botoes/irparamenu")
                    {
                        EstadoBase.estado_atual = EstadoBase.Estado.MENU;
                    }
                }
            }
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(textura, posicao, Color.White);
        }
    }
}